// common/homeswipr/homeswipr.js
const {
  jumpUrl,
  tagOperation
} = require('../../common/js/utils')
const app = getApp();
let api = require('../../common/js/api')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    bannerList: {
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    circular:true
  },

  /**
   * 组件的方法列表
   */
  methods: {
    bannerList(e){
      let pages = getCurrentPages()
      let prevPage = pages[pages.length - 1]
      if (prevPage.route == 'pages/my/my') {

      }

      /* 统计监测 */ 
      let jumpType = e.currentTarget.dataset.jumptype
      let jumpurl =  e.currentTarget.dataset.jumpurl
      let id = e.currentTarget.dataset.id
      console.log(e,'-- - ->')
      // return
      // jumpType 跳转类型（0：内部url，1：外部url，2：外部小程序）
      // jumpUrl  跳转路径
      console.log(wx.getStorageSync('userinfo').nickName,'- -- -- - -- -- >')
      if(jumpurl == '/pages/qna/index'){
        if (!wx.getStorageSync('userinfo').nickName){
          wx.navigateTo({
            url: '../qna/index',
          })
        }else{
          api.interface.gettitle().then(res=>{
          
            if (res.data.code == 200 && res.data.data.answered) {
                  wx.navigateTo({
                    url: '../qna/result',
                  })
              }else{
                wx.navigateTo({
                  url: '../qna/index',
                })
              }
          })
        }
      }else if(!wx.getStorageSync('userinfo').nickName){
        wx.navigateTo({
          url: '../authorization/authorization?act=' + 1,
        })
      }else{
        jumpUrl(jumpType,jumpurl)
      }
    }
  }
})